package com.zm.demo.shoppingmall.gateway.controller;

import com.zm.demo.shoppingmall.common.response.ShoppintMallResponse;
import com.zm.demo.shoppingmall.gateway.service.ProductManager;
import com.zm.demo.shoppingmall.product.model.TProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: z01140
 * @date: 2021/5/25 10:20
 */

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductManager productManager;

    @PostMapping("/addProduct")
    public ShoppintMallResponse addProduct(@RequestBody TProduct product){

        int r =  productManager.addProduct(product);
        return ShoppintMallResponse.response(1,"新增产品成功", r);
    }

    @GetMapping("/getStorageById")
    public ShoppintMallResponse getProductById(Integer productId){
        TProduct product =  productManager.getProductById(productId);
        return ShoppintMallResponse.response(1,"查询产品成功", product);
    }
}
